# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pytest-responsemock
pkgname=python-pytest-responsemock
pkgver=1.1.1
pkgrel=3
pkgdesc="Simplified requests calls mocking for pytest"
arch=(any)
url="https://github.com/idlesign/pytest-responsemock"
license=(BSD)
depends=(
  python
  python-pytest
  python-responses
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-requests)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('276b01afed3813a357d61dd0fb557824fc8001ae3c2f507bdcb05e12a5e2014e68102a14fc38e0565c304f963e5a5d152163e587fb55d0c46fea5f28a68ff247')
b2sums=('cbf90544a1e4c9a73e524c25a5bf0d418523ac4ae5576f42454ff9bbd81ecdf4d27daa7c0e433acd8fd9dc365992714d60ef73a5ddbe6ec45e4d1fb2076324c3')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
  pytest -v -k "not test_bypass"
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {AUTHORS,CHANGELOG,README.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
